#include "mappixmapitem.h"
#include <QGraphicsSceneMouseEvent>

MapPixmapItem::MapPixmapItem(QGraphicsItem * parent):
QGraphicsPixmapItem(parent)
{}

MapPixmapItem::~MapPixmapItem()
{}

void MapPixmapItem::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
    if(mouseEvent->buttons() & Qt::LeftButton)
    {
        QPointF dp = mouseEvent->scenePos() - mouseEvent->lastScenePos();
        emit moved(dp.x(), dp.y());
    }
    mouseEvent->accept();
}

void MapPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
//    clickPos = event->scenePos();
    event->accept();
}

void MapPixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
//    QPointF releasePos = event->scenePos();
//    if(cachedMoving && releasePos != clickPos)
//        emit moved((int)(releasePos.x() - clickPos.x()), (int)(releasePos.y() - clickPos.y()));
    event->accept();
}

void MapPixmapItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
{
    qDebug("%d, %d", event->pos().x(), event->pos().y());
    event->accept();
}
